﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Cost/Cost.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="LOGISTCBUS.Entities" %>
<%@ Import Namespace="LOGISTCBUS.DAO" %>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript" src="<%= Url.Content("~/Scripts/App/costEdit.js") %>"></script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <strong>CADASTRO DE DESPESA</strong>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%
        var c = this.ViewData["cost"] != null ? (Cost)this.ViewData["cost"] : new Cost();
    %>
    <div class="box">
        <div class="tabs">
            <ul>
                <li class="titleBox" style="padding: 3px 0 6px 10px;">Preencha os campos abaixo:</li>
            </ul>
            <div style="padding: 20px;" align="center">
                <div class="box" style="width: 500px;">
                    <div class="tabs">
                        <div style="padding: 10px;">
                            <input type="hidden" id="hdfIdCost" value="<%= c.Id %>" />
                            <table border="0" align="center" cellpadding="0" cellspacing="5" class="texto10azulclaro">
                                <tr>
                                    <td colspan="3" align="center">
                                        <p style='color: red; font-weight: bold;' id="lblMessage">
                                            <%= ViewData["error"] %>
                                        </p>
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Nome:
                                    </td>
                                    <td>
                                        <input type="text" name="txtName" id="txtName" class="fForm required" maxlength="100"
                                            style="width: 200px;" tabindex="1" value="<%= c.Name %>" />
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Tipo de Despesa:
                                    </td>
                                    <td>
                                        <select id="cboCostType" name="cboCostType" class="fForm" style="width: 201px;" tabindex="2">
                                            <option value="">--Selecione--</option>
                                            <%
                                                foreach (var ct in new CostTypeDAO().select())
                                                {
                                                    if (!String.IsNullOrEmpty(ct.Name))
                                                    {
                                                        var selected = "";
                                                        if (c != null && c.Id > 0 && c.CostType != null)
                                                            if (c.CostType.Id == ct.Id)
                                                                selected = " selected ";
                                            %>
                                            <option <%= selected %> value="<%= ct.Id %>">
                                                <%= ct.Name %>
                                            </option>
                                            <%      }
                                                }
                                            %>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Viagem:
                                    </td>
                                    <td>
                                        <select id="cboTrip" name="cboTrip" class="fForm" style="width: 201px;" tabindex="3">
                                            <option value="">--Selecione--</option>
                                            <%
                                                foreach (var t in new TripDAO().select())
                                                {
                                                    if (!String.IsNullOrEmpty(t.Code))
                                                    {
                                                        var selected = "";
                                                        if (c != null && c.Id > 0 && c.Trip != null)
                                                            if (c.Trip.Id == t.Id)
                                                                selected = " selected ";
                                            %>
                                            <option <%= selected %> value="<%= t.Id %>">
                                                <%= t.Code %>
                                            </option>
                                            <%      }
                                                }
                                            %>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Funcionário:
                                    </td>
                                    <td>
                                        <select id="cboEmployee" name="cboEmployee" class="fForm" style="width: 201px;" tabindex="4">
                                            <option value="">--Selecione--</option>
                                            <%
                                                foreach (var e in new EmployeeDAO().select())
                                                {
                                                    if (!String.IsNullOrEmpty(e.Name))
                                                    {
                                                        var selected = "";
                                                        if (c != null && c.Id > 0 && c.Employee != null)
                                                            if (c.Employee.Id == e.Id)
                                                                selected = " selected ";
                                            %>
                                            <option <%= selected %> value="<%= e.Id %>">
                                                <%= e.Name %>
                                            </option>
                                            <%      }
                                                }
                                            %>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Quantidade:
                                    </td>
                                    <td>
                                        <input type="text" name="txtQuantity" id="txtQuantity" class="fForm required" maxlength="100"
                                            style="width: 200px;" tabindex="5" value="<%= c.Quantity > 0 ? c.Quantity.ToString() : string.Empty %>" />
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Valor:
                                    </td>
                                    <td>
                                        <input type="text" name="txtValue" id="txtValue" class="fForm decimalfield required"
                                            maxlength="100" style="width: 200px;" tabindex="6" value="<%= c.Value > Decimal.Zero ? c.Value.ToString() : string.Empty %>" />
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Variável:
                                    </td>
                                    <td>
                                        <input type="text" name="txtVariable" id="txtVariable" class="fForm" maxlength="50"
                                            style="width: 200px;" tabindex="7" value="<%= c.Variable %>" />
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right" valign="middle">
                                        Descrição:
                                    </td>
                                    <td>
                                        <textarea id="txtDescription" rows="3" cols="100" class="fForm" style="width: 200px;
                                            height: 100px;" maxlength="500" tabindex="8"><%= c.Description %></textarea>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
                <div style="padding-top: 10px;">
                    <input name="btnSave" id="btnSave" type="button" value="Inserir" class="ui-button ui-state-default ui-corner-all botaoS"
                        tabindex="9" />
                </div>
            </div>
        </div>
    </div>
    <div align="center" class="texto10azulclaro" style="padding-top: 15px;">
        © 2014 - Todos os direitos reservados.
    </div>
</asp:Content>
